package string;

public class StringDemoTest {
    public static void main(String []args){
        String name1=getHostName("http://www.tedu.cn");
        String name2=getHostName("doc.canglaoshi.org");
        String name3=getHostName("www.tarena.com.cn");
        System.out.println(name1);
        System.out.println(name2);
        System.out.println(name3);
    }
    public static  String getHostName(String location){
        //先找到location中第一个"."和第二个"."
        int start=location.indexOf(".")+1;
        int end=location.indexOf(".",start);
        return location.substring(start,end);
    }
}
